package com.xyz.study.player;

/**
 * Player实现类
 * @author XYZ
 * @version 1.0
 * @since 2021/10/18
 */
public class PlayerImpl implements Player {

    private final String username;

    private boolean online;

    public PlayerImpl(String username, boolean online) {
        this.username = username;
        this.online = online;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getUsername() {
        return username;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void write(String message) {
        System.out.println("Player " + username + " Receive Message: " + message);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isOffline() {
        return !online;
    }
}
